// https://nuxt.com/docs/api/configuration/nuxt-config
import tailwindcss from '@tailwindcss/vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineNuxtConfig({
  compatibilityDate: '2024-11-01',
  devtools: { enabled: false },

  typescript: {
    typeCheck: false,
    strict: false,
  },
  app: {
    head: {
      title: '幻引官网',
      meta: [
        {
          name: 'description',
          content:
            '幻引官网提供先进的AI小助手和机器人解决方案，涵盖智能技术与新闻资讯。',
        },
        {
          name: 'keywords',
          content:
            'AI平台, 智能体, 智能体平台, AI定制, 企业AI, AI Flow, AI工作流, AI Agent, AI工具, AI流程, 增强搜索, RAG, 知识图谱, AI机器人定制, 专属AI, AI助手, LangChain, 大模型落地, 模型定制, AI场景落地, AI应用',
        },
        {
          charset: 'utf-8',
        },
        {
          name: 'viewport',
          content: 'width=device-width, initial-scale=1',
        },
      ],
      link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
    },
  },
  css: ['@/assets/css/common.scss', '@/assets/css/tailwind.css'],
  features: {
    inlineStyles: true,
  },
  build: {
    analyze: {
      analyzerMode: 'static',
    },
  },
  modules: ['@nuxt/image', '@nuxt/ui'],
  vite: {
    plugins: [
      tailwindcss(),
      ui({
        ui: {
          table: {
            slots: {
              root: 'relative overflow-auto',
              base: 'min-w-full overflow-clip',
              caption: 'sr-only',
              thead:
                'relative [&>tr]:after:absolute [&>tr]:after:inset-x-0 [&>tr]:after:bottom-0 [&>tr]:after:h-px [&>tr]:after:bg-(--ui-border-accented)',
              tbody:
                'divide-y divide-(--ui-border) [&>tr]:data-[selectable=true]:hover:bg-(--ui-bg-elevated)/50 [&>tr]:data-[selectable=true]:focus-visible:outline-(--ui-primary)',
              tr: 'data-[selected=true]:bg-(--ui-bg-elevated)/50',
              th: 'px-4 py-3.5 text-sm text-(--ui-text-highlighted) text-left rtl:text-right font-semibold [&:has([role=checkbox])]:pe-0 text-[14px]',
              td: 'p-4 text-sm text-(--ui-text-muted) whitespace-nowrap [&:has([role=checkbox])]:pe-0',
              empty: 'py-6 text-center text-sm text-(--ui-text-muted)',
              loading: 'py-6 text-center',
            },
            variants: {
              pinned: {
                true: {
                  th: 'sticky bg-(--ui-bg)/75 data-[pinned=left]:left-0 data-[pinned=right]:right-0',
                  td: 'sticky bg-(--ui-bg)/75 data-[pinned=left]:left-0 data-[pinned=right]:right-0',
                },
              },
              sticky: {
                true: {
                  thead:
                    'sticky top-0 inset-x-0 bg-(--ui-bg)/75 z-[1] backdrop-blur',
                },
              },
              loading: {
                true: {
                  thead:
                    'after:absolute after:bottom-0 after:inset-x-0 after:h-px',
                },
              },
              loadingAnimation: {
                carousel: '',
                'carousel-inverse': '',
                swing: '',
                elastic: '',
              },
              loadingColor: {
                primary: '#1955F7',
                secondary: '',
                success: '',
                info: '',
                warning: '',
                error: '',
                neutral: '',
              },
            },
            compoundVariants: [
              {
                loading: true,
                loadingColor: 'primary',
                class: {
                  thead: 'after:bg-(--ui-primary)',
                },
              },
              {
                loading: true,
                loadingColor: 'neutral',
                class: {
                  thead: 'after:bg-(--ui-bg-inverted)',
                },
              },
              {
                loading: true,
                loadingAnimation: 'carousel',
                class: {
                  thead:
                    'after:animate-[carousel_2s_ease-in-out_infinite] rtl:after:animate-[carousel-rtl_2s_ease-in-out_infinite]',
                },
              },
              {
                loading: true,
                loadingAnimation: 'carousel-inverse',
                class: {
                  thead:
                    'after:animate-[carousel-inverse_2s_ease-in-out_infinite] rtl:after:animate-[carousel-inverse-rtl_2s_ease-in-out_infinite]',
                },
              },
              {
                loading: true,
                loadingAnimation: 'swing',
                class: {
                  thead: 'after:animate-[swing_2s_ease-in-out_infinite]',
                },
              },
              {
                loading: true,
                loadingAnimation: 'elastic',
                class: {
                  thead: 'after:animate-[elastic_2s_ease-in-out_infinite]',
                },
              },
            ],
            defaultVariants: {
              loadingColor: 'primary',
              loadingAnimation: 'carousel',
            },
          },
        },
      }),
    ],
  },
  ui: {
    prefix: 'Nuxt',
    colorMode: false,
    fonts: false,
  },
  postcss: {
    plugins: {
      '@tailwindcss/postcss': {},
      'postcss-mobile-forever': {
        viewportWidth: 1440,
        unitPrecision: 6,
        // maxDisplayWidth: 1440,
        viewportUnit: 'vw',
        selectorBlackList: [],
        minPixelValue: 1,
        mediaQuery: false,
        enableMediaQuery: false,
        disableLandscape: false,
        // minWidth: 1446,
        minDisplayWidth: 1440,
        minDesktopDisplayWidth: 1440,
        // experimental: {
        //   minDisplayWidth: 1446,
        // },
      },
    },
  },

  router: {
    options: {
      // 将 linkActiveClass 和 linkExactActiveClass 嵌套到 options 中
      linkActiveClass: 'active-link',
      linkExactActiveClass: 'exact-active-link',
    },
  },
  routeRules: {
    '/api': {
      proxy: `https://ai.grawav.cn/api`,
    },
  },
  runtimeConfig: {
    public: {
      apiBase: process.env.API_BASE || 'https://ai.grawav.cn/api',
      baseUrl: process.env.API_BASE || 'https://ai.grawav.cn/api',
    },
  },
  nitro: {
    devProxy: {
      '/api': {
        target: 'https://ai.grawav.cn/api',
        changeOrigin: true,
        prependPath: true,
      },
    },
  },
})
